class Solution {
public:
    int firstUniqChar(string s) {
        int a[26];
        int end = s.size() - 1;
        for (char& ch : s) {
            a[ch - 97] += 1;
        }
        for (int i = 0; i <= end; i++) {
            if (a[s[i] - 97] == 1) {
                return i;
            }
        }
        return -1;
    }
};